package MEET.src.code;

import javax.swing.*;
import java.awt.*;

public class MeetingDetailDialog extends JDialog {
    public MeetingDetailDialog(JFrame parent, Meeting meeting) {
        super(parent, "会议详细信息", true);
        setSize(500, 400);
        setLocationRelativeTo(parent);

        JPanel panel = new JPanel();
        panel.setLayout(new GridLayout(0, 1, 10, 10));
        panel.setBorder(BorderFactory.createEmptyBorder(20, 20, 20, 20));

        if (meeting != null) {
            addDetailRow(panel, "会议号：", meeting.getMID());
            addDetailRow(panel, "会议名称：", meeting.getMname());
            addDetailRow(panel, "主持人：", meeting.getName());
            addDetailRow(panel, "会议起始时间：", meeting.getMstarttime().toString());
            addDetailRow(panel, "校区：", meeting.getPlace());
            addDetailRow(panel, "具体位置：", meeting.getLocation());
            addDetailRow(panel, "房间号：", meeting.getRoom());
            addDetailRow(panel, "会议形式：", meeting.getForm());
            addDetailRow(panel, "会议类型：", meeting.getType());
            addDetailRow(panel, "状态：", meeting.getStatus());
        } else {
            panel.add(new JLabel("未找到会议信息"));
        }

        JButton btnClose = new JButton("关闭");
        btnClose.addActionListener(e -> dispose());
        panel.add(btnClose);

        add(panel);
    }

    private void addDetailRow(JPanel panel, String label, String value) {
        JPanel rowPanel = new JPanel(new BorderLayout());
        rowPanel.add(new JLabel(label), BorderLayout.WEST);
        rowPanel.add(new JLabel(value), BorderLayout.CENTER);
        panel.add(rowPanel);
    }
}
